import {mapGetters} from 'vuex'
export default{
  methods:{
    setBadge(){
      uni.setTabBarBadge({
        index:2,
        text: this.total+ '' // 注意text一定要是字符串
      })
    }
  },
  onShow(){
    this.setBadge()
  },
  computed:{
    ...mapGetters('cart', ['total'])
  },
  watch:{
    total:{
      handler(newVal, oldVal){
        this.setBadge()
      },
      immediate: true
    }
  }
}